#include "stdafx.h"
#include "Utils.h"

/**
 * Wyswietlanie ukladu wspolrzednych w kolorach RGB
 */
void showCoordinates()
{
        glBegin(GL_LINES);
        glColor3f(1.0,0.5,0.5);
        glVertex3f(0.0,0.0,0.0);
        glVertex3f(5000.0,0.0,0.0);

        glColor3f(0.5,1.0,0.5);
        glVertex3f(0.0,0.0,0.0);
        glVertex3f(0.0,5000.0,0.0);

        glColor3f(0.5,0.5,1.0);
        glVertex3f(0.0,0.0,0.0);
        glVertex3f(0.0,0.0,5000.0);
        glEnd();
}


/**
* Funkcja pomocnicza konwertujaca String^ na float
*/
float StringHandleToFloat(System::String^ str){
	pin_ptr<const wchar_t> wch = PtrToStringChars(str);
	size_t convertedChars = 0;
	size_t  sizeInBytes = ((str->Length + 1) * 2);
	errno_t err = 0;
	char* ch = (char*)malloc(sizeInBytes);

	err = wcstombs_s(&convertedChars, 
                    ch, sizeInBytes,
                    wch, sizeInBytes);
	float value = (float)atof(ch);

	// [added by PB]
	free(ch);

	return value;
}
